package com.accp.vehiclecare.action.syhaction;

import com.accp.vehiclecare.biz.syhbiz.RepairbillBiz;
import com.accp.vehiclecare.pojo.Repairbill;
import com.accp.vehiclecare.vo.syhvo.DetailedVo;
import com.accp.vehiclecare.vo.syhvo.RepairbillVO;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("api/rep")
public class RepairbillAction {

    @Autowired
    private RepairbillBiz biz;

    @GetMapping
    private PageInfo<RepairbillVO> queryAll(Integer p,Integer s){
        return biz.queryAll(p, s,null);
    }

    @GetMapping("query/{id}")
    private DetailedVo queryone(@PathVariable Integer id){
        return biz.queryOne(id);
    }

    @PostMapping("/addwxd")
    private Map<String,Object> addRepairbill(@RequestBody Repairbill repairbill){
        Map<String,Object> m = new HashMap<>();
        if (biz.addRepairbill(repairbill)){
            m.put("code",200);
            m.put("msg","ok");
        }else {
            m.put("code",500);
            m.put("msg","no");
        }
        return m;
    }

    @GetMapping("jg")
    private PageInfo<RepairbillVO> queryZt(Integer p,Integer s,Integer zt){
        return biz.queryAll(p, s,zt);
    }

    @GetMapping("modifyZt")
    private Map<String,Object> modifyZt(String billNo,Integer zt) throws Exception{
        Map<String,Object> m = new HashMap<>();
        biz.modifyZt(billNo, zt);
        m.put("code",200);
        m.put("msg","ok");
        return m;
    }
}
